#include<iostream>
#include<algorithm>
using namespace std;
const int N = 1e5 + 10;
int arr[N];
int n;
int main()
{
	cin >> n;
	bool flag = 0;
	cin >> arr[0];
	int ma = 0;
	for (int i = 1; i < n; i++) {
		cin >> arr[i];
		if (arr[i] != arr[i - 1]) {
			flag = 1;
		}
		ma = max(ma, arr[i]);
	}
	if (flag) {
		cout << ma + 1 << endl;
	}
	else {
		cout << arr[0] << endl;
	}
	return 0;
}